package nl.hanze.FlitsNieuws.Domain;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Dit is de klasse die wordt gebruikt om de data in een nieuwsitem te transporteren naar de NetworkService
 * waar het item vervolgens wordt gepost. Het implementeert Parcelable, dit is het interface om (de-)serializen
 * van data in een android app mogelijk te maken. 
 *  
 * @author alex
 */
public class NewsItem implements Parcelable {
	// alle benodigde attributen om een nieuwsitem te versturen (inclusief credentials)
    private final String headLine;
    private final String newsText;
    private final String userName;
    private final String passWord;
    private final String lattitude;
    private final String longitude;
    private final String address;
    private final String city;
    private final String image;

    public NewsItem(String headLine, String newsText, String userName, String passWord, String lattitude, String longitude, String address, String city, String image) {
        this.headLine = headLine;
        this.newsText = newsText;
        this.userName = userName;
        this.passWord = passWord;
        this.lattitude = lattitude;
        this.longitude = longitude;
        this.address = address;
        this.city = city;
        this.image = image;
    }

    public String getHeadLine() {
        return headLine;
    }

    public String getNewsText() {
        return newsText;
    }

    public String getUserName() {
        return userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public String getLattitude() {
        return lattitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public String getAddress() {
        return address;
    }

    public String getCity() {
        return city;
    }

    public String getImage() {
        return image;
    }

    public NewsItem(Parcel in) {
        String data[] = new String[9];

        in.readStringArray(data);
        this.headLine = data[0];
        this.newsText = data[1];
        this.userName = data[2];
        this.passWord = data[3];
        this.lattitude = data[4];
        this.longitude = data[5];
        this.address = data[6];
        this.city = data[7];
        this.image = data[8];
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(new String[]{
                    this.headLine,
                    this.newsText,
                    this.userName,
                    this.passWord,
                    this.lattitude,
                    this.longitude,
                    this.address,
                    this.city,
                    this.image});
    }
    
    @SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
        public NewsItem createFromParcel(Parcel in) {
            return new NewsItem(in);
        }

        public NewsItem[] newArray(int size) {
            return new NewsItem[size];
        }
    };
}
